package com.herongo.controller;

import com.herongo.entity.*;
import com.herongo.service.IUserService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("good")
public class UserController {
    @Autowired
    private IUserService userService;

    @RequestMapping("detail")
    private ModelAndView queygoodDetailById(Integer goodId){
        ModelAndView mv = new ModelAndView();
        List<GoodDetailmg> slist = userService.queryImg(goodId);
        mv.addObject("",slist);
        return mv;
    }
    @RequestMapping("content")
    private ModelAndView queygoodContentById(Integer goodId){
        ModelAndView mv = new ModelAndView();
        List<GoodDetailContent> slist = userService.queryContent(goodId);
        mv.addObject("",slist);
        return mv;
    }
    @RequestMapping("heimg")
    private ModelAndView queygoodHeImgById(Integer goodId){
        ModelAndView mv = new ModelAndView();
        List<GoodHeadImg> slist = userService.queryGoodHeadImg(goodId);
        mv.addObject("",slist);
        return mv;
    }
   @RequestMapping("detailimg")
   @ApiOperation(value = "修改",httpMethod = "PUT")
   @ApiImplicitParams({
           @ApiImplicitParam(name = "good_detailImg_url",value = "轮播图路径",required = true,dataType = "int",paramType = "query",defaultValue = "1"),
           @ApiImplicitParam(name = "good_detailImg_ranking",value = "轮播图顺序",required = true,dataType = "String",paramType = "query"),
           @ApiImplicitParam(name = "good_detailContent_creatAt",value = "创建时间",required = true,dataType = "Data",paramType = "query"),
           @ApiImplicitParam(name = "good_detailContent_modifyAt",value = "修改时间",required = true,dataType = "Data",paramType = "query")
   })
    private boolean modifDetail(GoodDetailmg goodDetailmg){
      return userService.modifyDetaimg(goodDetailmg);
   }
    @RequestMapping("content")
    @ApiOperation(value = "修改",httpMethod = "PUT")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "good_detailContent_name",value = "详情图片路径",required = true,dataType = "int",paramType = "query",defaultValue = "1"),
            @ApiImplicitParam(name = "good_detailContent_value",value = "详情图片路径",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "good_detailContent_creatAt",value = "创建时间",required = true,dataType = "Data",paramType = "query"),
            @ApiImplicitParam(name = "good_detailContent_modifyAt",value = "修改时间",required = true,dataType = "Data",paramType = "query"),
    })
    private boolean modifContent(GoodDetailContent goodDetailContent){
        return userService.modifyDetailContent(goodDetailContent);
    }
    @RequestMapping("headimg")
    @ApiOperation(value = "修改",httpMethod = "PUT")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "good_headImg_url",value = "详情表格名",required = true,dataType = "int",paramType = "query",defaultValue = "1"),
            @ApiImplicitParam(name = "good_headImg_ranking",value = "详情表格内容",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "good_headImg_creatAt",value = "创建时间",required = true,dataType = "Data",paramType = "query"),
            @ApiImplicitParam(name = "good_headImg_modifyAt",value = "修改时间",required = true,dataType = "Data",paramType = "query")
    })
    private boolean modifHeImg(GoodHeadImg goodHeadImg){
        return userService.modifyDetaiHeImg(goodHeadImg);
    }
@RequestMapping("querycomment")
    private ModelAndView queryComment(Integer goodId){
        ModelAndView mv = new ModelAndView();
        List<GoodComment> list = userService.queryCommentList(goodId);
        mv.addObject(list);
        return mv;
}
        @RequestMapping(value = "addcomment",method = RequestMethod.POST)
        @ApiOperation(value = "添加",httpMethod = "POST")
        @ApiImplicitParams({
                @ApiImplicitParam(name = "user_id", value = "用户", required = false, dataType ="int", paramType = "query",defaultValue="0"),
                @ApiImplicitParam(name = "good_comment_level", value = "评论星级", required = true, dataType = "String", paramType = "form"),
                @ApiImplicitParam(name = "good_comment_content", value = "评论内容", required = true, dataType = "String", paramType = "form"),
                @ApiImplicitParam(name = "good_comment_creatAt", value = "创建时间", required = true, dataType = "Data", paramType = "form"),
        })
    private boolean addComment(GoodComment comment){
         return userService.addComment(comment);
     }
}